/**
 *  *2010-6-4 上午12:06:41  add 
 */
package com.base.myproject.client.ui.dialog;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.i18n.client.LocaleInfo;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.Image;

/**
 * 显示图片的类
 * ShowImageDialog.getInstance().show("", view.getSelectionModel().getSelectedItem().get("bcodeimagepath")+"");
							
 * @author Administrator
 *2010-6-4
 * javazgw@gmail.com
 */
public class ShowImageDialog {
	static ShowImageDialog showdialog = null;
	  final DialogBox dialogBox = new DialogBox();
	  HTML details = new HTML("");
	  Image image = new Image("");
	private ShowImageDialog()
	{
		 dialogBox.setGlassEnabled(true);
		    dialogBox.setAnimationEnabled(true);
		    dialogBox.ensureDebugId("imageDialogBox");
		    dialogBox.setText("查看");
		   
		    // Create a table to layout the content
		    com.google.gwt.user.client.ui.VerticalPanel dialogContents = new com.google.gwt.user.client.ui.VerticalPanel();
		    dialogContents.setSpacing(4);
		    dialogBox.setWidget(dialogContents);

		    // Add some text to the top of the dialog
		  
		    dialogContents.add(details);
		    dialogContents.setCellHorizontalAlignment(details,
		        HasHorizontalAlignment.ALIGN_CENTER);

		    // Add an image to the dialog
		   
		    dialogContents.add(image);
		    dialogContents.setCellHorizontalAlignment(image,
		        HasHorizontalAlignment.ALIGN_CENTER);

		    // Add a close button at the bottom of the dialog
		    com.google.gwt.user.client.ui.Button closeButton = new com.google.gwt.user.client.ui.Button ("关闭",
		        new ClickHandler() {
		          public void onClick(ClickEvent event) {
		            dialogBox.hide();
		          }
		        });
		    dialogContents.add(closeButton);
		    if (LocaleInfo.getCurrentLocale().isRTL()) {
		      dialogContents.setCellHorizontalAlignment(closeButton,
		          HasHorizontalAlignment.ALIGN_LEFT);

		    } else {
		      dialogContents.setCellHorizontalAlignment(closeButton,
		          HasHorizontalAlignment.ALIGN_RIGHT);
		    }
		    
	}
	static public ShowImageDialog getInstance()
	{
		if(showdialog==null)
		{
			showdialog = new ShowImageDialog();
		}
		return showdialog;
	}
	public void show(String htmltitle,String html)
	{
		details.setHTML(htmltitle);
		image.setUrl(html);
		 dialogBox.center();
		dialogBox.show();
	}
	
	 
}
